<?php
class person{
    private $name;
    public $age;
    public $sex;
    public function say(){
        echo "姓名：{$this->name}<br/>";
        echo "年龄：{$this->age}<br/>";
        echo "性别：".$this->sex."<br/>";
    }
    public function __construct($a,$b,$c){
        $this->name=$a;
        $this->age=$b;
        $this->sex=$c;
    }
    public function __set($name, $value)
    {
        $this->name=$value;
    }
}
$zhangsan=new person("张三",34,"f");
$zhangsan->say();
$zhangsan->name="nia";
$zhangsan->say();